from rest_framework import serializers

from algorithm.models import TagDependency, TagImportance, TagValue, UserComprehensiveLevel, UserProblemRecommendation, \
    UserTagMastery


class TagDependencySerializer(serializers.ModelSerializer):
    class Meta:
        model = TagDependency
        fields = ['source_tag', 'target_tag', 'weight']


class FrontEndTagDependencySerializer(serializers.ModelSerializer):
    source = serializers.CharField(source='source_tag.index', read_only=True)
    target = serializers.CharField(source='target_tag.index', read_only=True)

    class Meta:
        model = TagDependency
        fields = ['source', 'target']



class TagImportanceSerializer(serializers.ModelSerializer):
    class Meta:
        model = TagImportance
        fields = ['tag', 'importance_score']


class TagValueSerializer(serializers.ModelSerializer):
    class Meta:
        model = TagValue
        fields = ['tag', 'tag_value']


class UserComprehensiveLevelSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserComprehensiveLevel
        fields = ['user', 'tag_solving_level', 'user_level']


class UserProblemRecommendationSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProblemRecommendation
        fields = ['user', 'problem', 'recommendation_score']


class UserTagMasterySerializer(serializers.ModelSerializer):
    class Meta:
        model = UserTagMastery
        fields = ['user', 'tag', 'mastery_score', 'mastery_level', 'recommendation_score']


